<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>服务处理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/font.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">服务</a>
        <a>
          <cite>处理</cite></a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so" onsubmit="return false;">
            <input type="text" name="keywords"  placeholder="请输入服务名称" autocomplete="off" class="layui-input">
            <div class="layui-input-inline">
                <select name="serveStatus" lay-verify="required">
                    <option value="2">已分配</option>
                </select>
            </div>
            <div class="layui-input-inline">
                <%--                <select name="contrller">--%>
                <select name="serveType" lay-verify="required">
                    <option value=""></option>
                    <option value="1">售后服务</option>
                    <option value="2">售前服务</option>
                    <option value="3">投诉服务</option>
                    <option value="4">咨询服务</option>
                </select>
            </div>
            <button class="layui-btn" id="search" ><i class="layui-icon">&#xe615;</i></button>
        </form>
    </div>

    <xblock class="do-table">


    </xblock>
    <table id="data" lay-filter="serve"></table>


</div>
<script>
    var table;
    layui.use(['laydate','table'], function(){
        var laydate = layui.laydate;
        table = layui.table;
        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });
        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });

        table.render({
            elem: '#data'
            ,height: 600
            ,url: '${pageContext.request.contextPath}/serve/list/data' //数据接口
            ,method: "post"
            ,page: true //开启分页
            ,cols: [[ //表头

                {type:'checkbox', fixed: 'left'}
                ,{field: 'serveId', title: 'ID', width:'5%', sort: true}
                ,{field: 'serveName', title: '服务名称', width:'20%'}
                ,{field: 'serveType', title: '类型', width:'10%', templet:function (d) {
                        if (d.serveType === 1){return "售后服务"}
                        else if(d.serveType === 2){return "售前服务"}
                        else if(d.serveType === 3){return "投诉服务"}
                        else if(d.serveType === 4){return "咨询服务"}

                    }}
                ,{field: 'serveStatus', title: '状态', width:'10%', templet:function (d) {
                        if (d.serveStatus === 1){return "新创建"}
                        else if(d.serveStatus === 2){return "已提交"}
                        else if(d.serveStatus === 3){return "已分配"}
                        else if(d.serveStatus === 4){return "已反馈"}
                        else if(d.serveStatus === 0){return "已处理"}

                    }}

                ,{field: 'lastServeTime', title: '最后操作时间', width: '15%', sort: true, templet:function (d) {
                        return d.lastServeTime==null ? '未登录' : d.lastServeTime;
                    }}

                ,{field: 'serveOperator', title: '操作人', width: '20%', templet:function (d) {
                        return d.empl.emplRealName;
                    }}
                ,{field: 'servePending',title: '待处理人', width:'20%',  templet:function (d) {
                        return d.servePending === null ? 'null' : d.empl1.emplRealName;

                    }}
                ,{fixed: 'right',title: '操作', width:'20%', align:'center', toolbar: '#do'}
            ]]
        });
        //工具条事件
        table.on('tool(serve)', function(obj){ //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            var tr = obj.tr; //获得当前行 tr 的 DOM 对象（如果有的话）


            if(layEvent === 'view'){ //查看
                //do something
                x_admin_show('查看服务','${pageContext.request.contextPath}/serve/view/page?id='+data.serveId)
            }
            else if(layEvent === 'conduct'){ //处理
                //do something
                x_admin_show('处理服务','${pageContext.request.contextPath}/serve/conductStatus/page?id='+data.serveId)
            }
            else if(layEvent === 'LAYTABLE_TIPS'){
                layer.alert('Hi，头部工具栏扩展的右侧图标。');
            }
        });


        $('.do-table .layui-btn-danger').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });


        $("#search").click(function () {
            //获取对应的数据
            // 获取关键字
            var keywords = $("input[name='keywords']").val();
            var serveStatus = $("select[name='serveStatus']").val();
            var serveType = $("select[name='serveType']").val();
            // console.log(serveName);
            // console.log(serveType);
            // console.log(serveStatus);
            // 组装总共的提交参数
            var param = {keywords: keywords,serveStatus: serveStatus,serveType: serveType};

            // 表格数据的重载
            table.reload("data",{where: param})
        });
    });

</script>


<script type="text/html" id="do">
    <a class="layui-btn layui-btn-xs" lay-event="view">查看</a>
    <a class="layui-btn layui-btn-xs" lay-event="conduct">处理</a>

</script>

</body>

</html>